package com.jason.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jason.service.IndexService;
import jdk.internal.org.objectweb.asm.tree.analysis.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.Map;

@Controller
@RequestMapping("/index")
public class IndexController {
    @Resource
    private IndexService indexService;
    @RequestMapping("/index")
    public String index(Model model,
                        @RequestParam(value = "psize",defaultValue = "1") int psize,
                        @RequestParam(value = "pageSize",defaultValue = "8") int pageSize){//WEB层
     System.out.println("接收到一个浏览器的请求......");
     //调用Service层首页数据
     Map<String, Page> resultMap=indexService.index(psize,pageSize);
     //将数据放到model---数据
     model.addAttribute("resultMap",resultMap);
     //返回view--html
     return "index";
 }
}
